<div class="posts index">
	<table class="blog">
		<?php foreach ($posts as $post): ?>
		<tr>
			<td>
			<table width="100%" cellpadding="10" cellspacing="0" class="post">
				<tr>
					<td><?php echo $this->Html->link('<h2>'.$post['Post']['name'].'</h2>', array('action' => 'view', $post['Post']['id']),array('escape'=>false)); ?>
						<span class="modified-date"><?php echo $post['Post']['modified']; ?></span>&nbsp;
					</td>
				</tr>
				<tr>
					<td class="content">
					<?php echo $this->Text->truncate(
						    $post['Post']['content'],
						    150,
						    array(
						        'ending' => '...',
						        'exact' => true,
						    	'html' => true
						    ));
					?>&nbsp;</td>
				</tr>
				<tr>
					<td>
						<table class="corners" bgcolor="#bbbbbb" cellpadding="4" width="100%" cellspacing="4">
							<tr>
								<td valign="middle" width="12%">
									<?php echo __('Comments:',true)?>
								</td>
								<td valign="middle" align="center" width="3%">
									<?php echo count($post['Comment'])?>
									
								</td>
								<td valign="middle" width="45%">&nbsp;</td>
								<td align="right" valign="middle" width="40%">
									<?php echo $this->Html->link(__('+ add comment',true), array('controller'=>'comments','action' => 'add', $post['Post']['id']),array('class'=>'button corners')); ?>
									&nbsp;&nbsp;
									<?php echo $this->Html->link(__('view post',true), array('controller'=>'posts','action' => 'view', $post['Post']['id']),array('class'=>'button corners')); ?>
								</td>								
							</tr>
						</table>
					</td>
				</tr>
			</table>
			</td>
		</tr>
		<?php endforeach; ?>
	</table>
	<p>
		<?php
		echo $this->Paginator->counter(array(
		'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
		));
		?>	
	</p>
	
	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 	<?php echo $this->Paginator->numbers(array('separator'=>false));?>
	 	<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>

<?php if($session->check('Auth.User.id')){?>
<?php echo $this->element('toolbar_actions_main',array('plugin'=>'blog','toolbar'=>'posts'))?>
<?php }?>	